1. Field of the Invention
Embodiments of the present invention relate generally to context switching and, more particularly, to context switching that employs a halt sequencing protocol.
2. Description of the Related Art
A context switch is a feature of a multitasking operating system that allows for a switch in execution from one computing thread or process to another. This feature ensures that a processor cannot be monopolized by any one processor-intensive thread or process. During a context switch, the states of the processor of the currently running process are stored in memory and the processor is restored with states of another process that was previously stored in memory.
In graphics applications, a number of threads may be multiprocessed through a graphics pipeline that is managed by a graphics processing unit (GPU). A simplified diagram of a graphics pipeline 100 is illustrated in FIG. 1. The graphics pipeline 100, as shown, includes a front end (FE) 110, a number of processing units 120, and a raster operations unit 130. Part of the FE 110 is a unit of the graphics pipeline 100. This part decodes the commands that are to be processed by the other units of the graphics pipeline 100. Additional details of a graphics pipeline and the functions of each of the units of the graphics pipeline are described in U.S. patent application Ser. No. 11/009,471, filed Dec. 10, 2004, entitled “Fragment Processor Having Dual Mode Register File,” the entire contents of which are incorporated by reference herein.
The input to the graphics pipeline 100 is a host unit 105. The host unit 105 schedules the processing of different threads through the graphics pipeline 100. The output of the graphics pipeline 100 is a frame buffer 135, which stores the data of the image to be displayed. A memory unit 140 for storing different contexts of the graphics pipeline 100 is also provided. During a context switch, the FE 110 stores the current context (states) of the graphics pipeline 100 in the memory unit and restores the graphics pipeline 100 to a context that has been previously stored in the memory unit 140.
A context switch does not occur immediately upon a command from the host unit 105. When the FE 110 receives a context switch command from the host unit 105, it suspends sending commands down the graphics pipeline 100 and then waits for an idle status signal from each of the units of the graphics pipeline 100. A context switch occurs only after the FE 110 receives an idle status signal from each of the units of the graphics pipeline 100. This ensures that the graphics pipeline 100 is completely drained before the context switch.
The context switch protocol described above is known as the wait-for-idle (WFI) protocol. The architecture that implements the WFI protocol is illustrated in FIG. 2. In FIG. 2, separate connections from each unit of the graphics pipeline 100 to the FE 110 are collectively represented by the reference numeral 210 and shown superimposed on the graphics pipeline 100 illustrated in FIG. 1. At each clock, each unit of the graphics pipeline 100 reports back its status (idle or non-idle) to the FE 110. A context switch occurs when the FE 110 receives a context switch command from the host unit 105 and all of the units of the graphics pipeline 100 are reporting that they are idle. During a context switch, the FE 110 dumps the state information of each unit of the graphics pipeline 100 into the memory unit 140, and restores the units of the graphics pipeline 100 with state information retrieved from the memory unit 140 that corresponds to a thread that is scheduled to be processed by the graphics pipeline 100 after the context switch.